<template>
  <div class="app-container">
    <el-form :inline="true" :model="formInline" ref="formInline" class="demo-form-inline">
      <el-form-item label="调整时间" prop="time">
        <el-date-picker
          v-model="formInline.time"
          type="datetimerange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          :default-time="['00:00:00', '23:59:59']"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :picker-options="pickerDayStep">
        </el-date-picker>
      </el-form-item>
<el-form-item label="调整方式" prop="optType">
        <el-select v-model="formInline.optType" placeholder="全部">
          <el-option
            v-for="item in consts.MEMBER_LEVEL_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>

      </el-form-item>
      <el-form-item label="调整人" prop="creator">
        <el-input v-model="formInline.creator" placeholder="请输入调整人" @keyup.enter.native="handleFilter">
        </el-input>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
      <el-button @click="cancel('formInline')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
import { form, pickerOption } from '@/build';

export default {
  name: 'form-level-filter',
  mixins: [form, pickerOption],
  data() {
    return {
      formInline: {
        orderType: [1, 2, 3, 4, 5, 6],
        time: [moment().startOf('month').format('YYYY-MM-DD 00:00:00'), moment().format('YYYY-MM-DD 23:59:59')],
        optType: -1,
        creator: '', // 调整人
      },
    };
  },
  methods: {
    _exportExcel() {
      this.$emit('on-export', this.formInline);
    },
    handleFilter() {
      this.$emit('on-filter', this.formInline);
    },
    cancel(formName) {
      this.resetForm(formName);
      this.handleFilter();
    },
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 80px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
